<template>
  <wd-config-provider :themeVars="themeVars" class="fixed bottom-0 left-0 right-0">
    <slot />
    <wd-toast />
    <wd-message-box />
  </wd-config-provider>
</template>

<script lang="ts" setup>
import type { ConfigProviderThemeVars } from 'wot-design-uni'
import { useUserStore } from '@/store/user'
import { ref } from 'vue'

const userStore = useUserStore()
const role = userStore.currentCommunity?.role
const isShowUserManage = role === 'ADMIN' || role === 'PMC_WORKER'
const themeVars: ConfigProviderThemeVars = {
  // colorTheme: 'red',
  // buttonPrimaryBgColor: '#07c160',
  // buttonPrimaryColor: '#07c160',
}
const handleTabbarChange = ({ value }: { value: string }) => {
  if (value === 'userManage') {
    uni.navigateTo({ url: '/pages/community-users/index' })
  } else if (value === 'user') {
    uni.navigateTo({ url: '/pages/about/about' })
  } else if (value === 'open') {
    uni.navigateTo({ url: '/pages/index/index' })
  }
}

const tabbar = ref('open')

onLoad(() => {
  const pages = getCurrentPages()
  const currentPage = pages[pages.length - 1]
  const path = currentPage.route

  if (path.includes('community-users')) {
    tabbar.value = 'userManage'
  } else if (path.includes('about')) {
    tabbar.value = 'user'
  } else if (path.includes('index')) {
    tabbar.value = 'open'
  }
})
</script>
